package com.warm.mini.wework.constant;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Description 企微模块枚举
 * @Author warmchuang
 * @Date 2022/2/9 17:55
 */
@Getter
public enum WeworkModelEnum {
    CONTACT("contact", "通讯录事件"),
    EXTERNAL_CONTACT("external_contact", "外部联系人事件"),
    BUILD_APPLICATION("build_application", "自建应用")
    ;

    private String value;
    private String text;

    WeworkModelEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public static WeworkModelEnum getByName(String modelName){
        Optional<WeworkModelEnum> first = Arrays.stream(WeworkModelEnum.values()).filter(enm -> enm.getValue().equals(modelName)).findFirst();
        return first.isPresent() ? first.get() : null;
    }
}
